<?php
/**
 * Created by PhpStorm.
 * User: James
 * Date: 2016/9/13
 * Time: 17:19
 */

namespace Common\Controller;


class WeixinbaseController extends AdminbaseController
{
    protected $access_token;
    protected $access_token_url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET";
    protected $appID;
    protected $appsecret;


    function _initialize()
    {
        parent::_initialize();
        $this->appID =C('WEIXIN_APPID');
        $this->appsecret =C('WEIXIN_APPSECRET');
        $this->access_token=cookie('access_token');
        if (empty($this->access_token)){
            $url =replace_appID_APPSecret($this->access_token_url,$this->appID,$this->appsecret);
            $data =json_decode(file_get_contents($url),true);
            cookie('access_token',$data['access_token'],$data['expires_in']);
            $this->access_token=$data['access_token'];
        }

    }
    
    
    
    
    
    
}